export function formatYearMonthDate(timestamp) {
  const time = new Date(timestamp)
  const year = time.getFullYear()
  const month = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1
  const date = time.getDate() < 10 ? '0' + (time.getDate()) : time.getDate()
  return year + '-' + month + '-' + date
}

export function formatTime(timestamp) {
  const time = new Date(timestamp)
  const year = time.getFullYear()
  const month = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1
  const date = time.getDate() < 10 ? '0' + (time.getDate()) : time.getDate()
  const hour = time.getHours() < 10 ? '0' + (time.getHours()) : time.getHours()
  const minute = time.getMinutes() < 10 ? '0' + (time.getMinutes()) : time.getMinutes()
  const second = time.getSeconds() < 10 ? '0' + (time.getSeconds()) : time.getSeconds()
  return year + '-' + month + '-' + date + ' ' + hour + ':' + minute + ':' + second
}

export function formatTimeToObj(timestamp) {
  const time = new Date(timestamp)
  const year = time.getFullYear()
  const month = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1
  const date = time.getDate() < 10 ? '0' + (time.getDate()) : time.getDate()
  const hour = time.getHours() < 10 ? '0' + (time.getHours()) : time.getHours()
  const minute = time.getMinutes() < 10 ? '0' + (time.getMinutes()) : time.getMinutes()
  const second = time.getSeconds() < 10 ? '0' + (time.getSeconds()) : time.getSeconds()
  return {
    year: year,
    month: month,
    date: date,
    hour: hour,
    minute: minute,
    second: second
  }
}

export function formatTimeToObjInteger(timestamp) {
  const time = new Date(timestamp)
  const year = time.getFullYear()
  const month = time.getMonth() + 1
  const date = time.getDate()
  const hour = time.getHours()
  const minute = time.getMinutes()
  const second = time.getSeconds()
  return {
    year: year,
    month: month,
    date: date,
    hour: hour,
    minute: minute,
    second: second
  }
}

export function formatYMD(timestamp) {
  const time = new Date(timestamp)
  const year = time.getFullYear()
  const month = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1
  const date = time.getDate() < 10 ? '0' + (time.getDate()) : time.getDate()
  return year + '-' + month + '-' + date + ' ' + '00' + ':' + '00' + ':' + '00'
}
